
/*  A Bison parser, made from pddl.yy
    by GNU Bison version 1.28  */

#define YYBISON 1  /* Identify Bison output.  */

#define	DEFINE	257
#define	DOMAIN_TOKEN	258
#define	PROBLEM	259
#define	REQUIREMENTS	260
#define	STRIPS	261
#define	TYPING	262
#define	NEGATIVE_PRECONDITIONS	263
#define	DISJUNCTIVE_PRECONDITIONS	264
#define	EQUALITY	265
#define	EXISTENTIAL_PRECONDITIONS	266
#define	UNIVERSAL_PRECONDITIONS	267
#define	QUANTIFIED_PRECONDITIONS	268
#define	CONDITIONAL_EFFECTS	269
#define	FLUENTS	270
#define	ADL	271
#define	DURATIVE_ACTIONS	272
#define	DURATION_INEQUALITIES	273
#define	CONTINUOUS_EFFECTS	274
#define	TYPES	275
#define	CONSTANTS	276
#define	PREDICATES	277
#define	ACTION	278
#define	DURATIVE_ACTION	279
#define	DURATION	280
#define	PARAMETERS	281
#define	PRECONDITION	282
#define	CONDITION	283
#define	EFFECT	284
#define	PDOMAIN	285
#define	OBJECTS	286
#define	INIT	287
#define	GOAL	288
#define	METRIC	289
#define	WHEN	290
#define	NOT	291
#define	AND	292
#define	OR	293
#define	IMPLY	294
#define	EXISTS	295
#define	FORALL	296
#define	EITHER	297
#define	AT	298
#define	OVER	299
#define	START	300
#define	END	301
#define	ALL	302
#define	MINIMIZE	303
#define	MAXIMIZE	304
#define	TOTAL_TIME	305
#define	LE	306
#define	GE	307
#define	NAME	308
#define	DURATION_VAR	309
#define	VARIABLE	310
#define	NUMBER	311
#define	ILLEGAL_TOKEN	312

#line 21 "pddl.yy"

#include <typeinfo>
#include <utility>
#include <cstdlib>
#include "mathport.h"
#include "requirements.h"
#include "problems.h"
#include "domains.h"
#include "formulas.h"
#include "types.h"


/* The lexer. */
extern int yylex();
/* Current line number. */
extern size_t line_number;
 

static string tostring(unsigned int n);
static void yyerror(const string& s); 
static void yywarning(const string& s);
static const SimpleType* find_type(const string& name);
static const Name* find_constant(const string& name);
static const Predicate* find_predicate(const string& name);
static void add_names(const vector<string>& names,
		      const Type& type = SimpleType::OBJECT);
static void add_predicate(const Predicate& predicate);
static void add_action(const ActionSchema& action);
static void add_variable(const string& name,
			 const Type& type = SimpleType::OBJECT);
static const pair<AtomList*, NegationList*>& make_add_del(AtomList* adds,
							  NegationList* dels);
static const Atom& make_atom(const string& predicate, const TermList& terms);
static TermList& add_name(TermList& terms, const string& name);
static const SimpleType& make_type(const string& name);


/*
 * Context of free variables.
 */
struct Context {
  void push_frame() {
    frames_.push_back(VariableMap());
  }

  void pop_frame() {
    frames_.pop_back();
  }

  void insert(const Variable* v) {
    frames_.back()[v->name()] = v;
  }

  const Variable* shallow_find(const string& name) const {
    VariableMap::const_iterator vi = frames_.back().find(name);
    return (vi != frames_.back().end()) ? (*vi).second : NULL;
  }

  const Variable* find(const string& name) const {
    for (vector<VariableMap>::const_reverse_iterator fi = frames_.rbegin();
	 fi != frames_.rend(); fi++) {
      VariableMap::const_iterator vi = (*fi).find(name);
      if (vi != (*fi).end()) {
	return (*vi).second;
      }
    }
    return NULL;
  }

private:
  struct VariableMap : public hash_map<string, const Variable*> {
  };

  vector<VariableMap> frames_;
};


/* Name of current file. */
string current_file; 
/* Level of warnings. */
int warning_level;

static const Variable DURATION_VARIABLE =
  Variable("?duration", SimpleType::OBJECT);
static bool success = true;
static const Domain* pdomain;
static Domain* domain;
static Requirements* requirements;
static Predicate* predicate = NULL;
static Problem* problem;
static string current_predicate;
static string context;
static enum { TYPE_MAP, CONSTANT_MAP, OBJECT_MAP } name_map_type;
static const Formula* action_precond; 
static const EffectList* action_effs;
static pair<float, float> action_duration;
static Formula::FormulaTime formula_time;
static VariableList* variables;
static Context free_variables;

#line 138 "pddl.yy"
typedef union {
  const ActionSchema* action;
  const Formula* formula;
  EffectList* effects;
  const Effect* effect;
  const pair<AtomList*, NegationList*>* add_del_lists;
  FormulaList* formulas;
  TermList* terms;
  const Atom* atom;
  const Name* name;
  VariableList* variables;
  const Variable* variable;
  const string* str;
  float num;
  vector<string>* strings;
  UnionType* utype;
  const Type* type;
} YYSTYPE;
#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		430
#define	YYFLAG		-32768
#define	YYNTBASE	66

#define YYTRANSLATE(x) ((unsigned)(x) <= 312 ? yytranslate[x] : 186)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,    59,
    60,    64,    62,     2,    63,     2,    65,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    61,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
     7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
    17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
    27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
    37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
    47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
    57,    58
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     1,     4,     5,     8,    10,    12,    13,    23,    24,
    26,    29,    31,    33,    36,    38,    41,    45,    47,    49,
    52,    54,    56,    59,    61,    63,    66,    71,    73,    76,
    78,    80,    82,    84,    86,    88,    90,    92,    94,    96,
    98,   100,   102,   104,   105,   111,   112,   118,   123,   125,
   128,   129,   135,   136,   147,   148,   159,   162,   164,   165,
   167,   168,   172,   175,   177,   182,   183,   192,   193,   200,
   201,   204,   206,   211,   212,   215,   217,   222,   226,   230,
   232,   233,   236,   238,   243,   249,   255,   261,   262,   265,
   267,   272,   273,   276,   277,   284,   285,   292,   293,   300,
   302,   307,   308,   317,   323,   324,   327,   328,   335,   336,
   343,   344,   345,   360,   363,   365,   368,   370,   373,   375,
   376,   382,   383,   389,   391,   394,   396,   401,   402,   408,
   409,   412,   415,   417,   419,   422,   423,   429,   435,   437,
   439,   445,   451,   457,   463,   465,   470,   472,   473,   475,
   476,   479,   481,   486,   491,   496,   501,   507,   508,   517,
   518,   527,   528,   534,   535,   538,   541,   542,   544,   546,
   547,   552,   553,   555,   557,   560,   561,   563,   564,   567,
   569,   570,   575,   576,   578,   580,   583,   585,   588,   591,
   593,   598,   600,   602,   604,   606,   608,   610,   612,   614,
   616,   618,   620,   622,   624,   626,   628,   630,   632,   634,
   636,   638,   640,   642,   644,   646,   648,   650,   652,   654,
   656,   658,   660,   662,   664,   666,   668,   670,   672,   674,
   676,   678,   680,   682,   684,   686,   688,   690,   692,   694,
   696,   698,   700,   702,   704,   706,   708,   710,   712,   714,
   716,   718,   720,   722,   724,   726,   728,   730,   732,   734,
   736
};

static const short yyrhs[] = {    -1,
    67,    68,     0,     0,    68,    69,     0,    70,     0,   122,
     0,     0,    59,   167,    59,    70,   185,    60,    71,    72,
    60,     0,     0,    78,     0,    78,    73,     0,    73,     0,
    81,     0,    81,    74,     0,    74,     0,    85,    83,     0,
    85,    83,    77,     0,    75,     0,    83,     0,    83,    76,
     0,    76,     0,    85,     0,    85,    77,     0,    77,     0,
    89,     0,    77,    89,     0,    59,     6,    79,    60,     0,
    80,     0,    79,    80,     0,     7,     0,     8,     0,     9,
     0,    10,     0,    11,     0,    12,     0,    13,     0,    14,
     0,    15,     0,    16,     0,    17,     0,    18,     0,    19,
     0,    20,     0,     0,    59,    21,    82,   152,    60,     0,
     0,    59,    22,    84,   152,    60,     0,    59,    23,    86,
    60,     0,    87,     0,    86,    87,     0,     0,    59,   183,
    88,   157,    60,     0,     0,    59,    24,   185,    90,    27,
    59,   157,    60,    92,    60,     0,     0,    59,    25,   185,
    91,    27,    59,   157,    60,   104,    60,     0,    94,    93,
     0,    93,     0,     0,    96,     0,     0,    28,    95,   146,
     0,    30,    97,     0,   103,     0,    59,   170,   100,    60,
     0,     0,    59,   174,    98,    59,   157,    60,    97,    60,
     0,     0,    59,   168,    99,   146,   101,    60,     0,     0,
   100,    97,     0,   103,     0,    59,   170,   102,    60,     0,
     0,   102,   103,     0,   149,     0,    59,   169,   149,    60,
     0,    26,   107,   105,     0,    29,   110,   106,     0,   106,
     0,     0,    30,   116,     0,   108,     0,    59,   170,   109,
    60,     0,    59,    52,   181,    57,    60,     0,    59,    53,
   181,    57,    60,     0,    59,    61,   181,    57,    60,     0,
     0,   109,   108,     0,   112,     0,    59,   170,   111,    60,
     0,     0,   111,   112,     0,     0,    59,   176,   178,   113,
   146,    60,     0,     0,    59,   176,   179,   114,   146,    60,
     0,     0,    59,   177,   180,   115,   146,    60,     0,   119,
     0,    59,   170,   118,    60,     0,     0,    59,   174,   117,
    59,   157,    60,   116,    60,     0,    59,   168,   110,   119,
    60,     0,     0,   118,   116,     0,     0,    59,   176,   178,
   120,   101,    60,     0,     0,    59,   176,   179,   121,   101,
    60,     0,     0,     0,    59,   167,    59,   122,   185,    60,
   123,    59,    31,   185,    60,   124,   125,    60,     0,    78,
   126,     0,   126,     0,   128,   127,     0,   127,     0,   130,
   137,     0,   137,     0,     0,    59,    32,   129,   152,    60,
     0,     0,    59,    33,   131,   132,    60,     0,   133,     0,
   132,   133,     0,   134,     0,    59,   169,   134,    60,     0,
     0,    59,   183,   135,   136,    60,     0,     0,   136,   185,
     0,   138,   141,     0,   138,     0,   139,     0,   138,   139,
     0,     0,    59,    34,   140,   146,    60,     0,    59,    35,
   142,   143,    60,     0,    49,     0,    50,     0,    59,    62,
   143,   143,    60,     0,    59,    63,   143,   144,    60,     0,
    59,    64,   143,   143,    60,     0,    59,    65,   143,   143,
    60,     0,    57,     0,    59,   184,   136,    60,     0,   184,
     0,     0,   143,     0,     0,   145,   146,     0,   149,     0,
    59,    61,   151,    60,     0,    59,   169,   146,    60,     0,
    59,   170,   145,    60,     0,    59,   171,   145,    60,     0,
    59,   172,   146,   146,    60,     0,     0,    59,   173,   147,
    59,   157,    60,   146,    60,     0,     0,    59,   174,   148,
    59,   157,    60,   146,    60,     0,     0,    59,   183,   150,
   151,    60,     0,     0,   151,   185,     0,   151,   182,     0,
     0,   153,     0,   156,     0,     0,   156,   165,   154,   155,
     0,     0,   153,     0,   185,     0,   156,   185,     0,     0,
   158,     0,     0,   159,   160,     0,   163,     0,     0,   163,
   165,   161,   162,     0,     0,   160,     0,   182,     0,   163,
   182,     0,   183,     0,   164,   183,     0,    63,   166,     0,
   183,     0,    59,   175,   164,    60,     0,     3,     0,     4,
     0,     5,     0,    36,     0,    37,     0,    38,     0,    39,
     0,    40,     0,    41,     0,    42,     0,    43,     0,    44,
     0,    45,     0,    46,     0,    47,     0,    48,     0,    55,
     0,    55,     0,    56,     0,    54,     0,     3,     0,     4,
     0,     5,     0,    44,     0,    45,     0,    46,     0,    47,
     0,    48,     0,    49,     0,    50,     0,    54,     0,     3,
     0,     4,     0,     5,     0,    36,     0,    37,     0,    38,
     0,    39,     0,    40,     0,    41,     0,    42,     0,    43,
     0,    44,     0,    45,     0,    46,     0,    47,     0,    48,
     0,    49,     0,    50,     0,    51,     0,    54,     0,     3,
     0,     4,     0,     5,     0,    36,     0,    37,     0,    38,
     0,    39,     0,    40,     0,    41,     0,    42,     0,    43,
     0,    44,     0,    45,     0,    46,     0,    47,     0,    48,
     0,    49,     0,    50,     0,    51,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
   185,   185,   188,   189,   192,   193,   201,   210,   213,   214,
   215,   216,   219,   220,   221,   224,   225,   226,   229,   230,
   231,   234,   235,   236,   239,   240,   243,   246,   247,   250,
   252,   257,   259,   261,   263,   265,   267,   269,   271,   273,
   275,   277,   279,   283,   292,   295,   299,   302,   305,   306,
   309,   314,   326,   332,   340,   352,   364,   365,   368,   369,
   372,   373,   376,   379,   385,   387,   395,   419,   420,   440,
   442,   445,   446,   450,   452,   463,   465,   469,   472,   473,
   476,   477,   480,   481,   491,   503,   515,   527,   528,   531,
   532,   541,   542,   545,   545,   547,   547,   549,   549,   553,
   554,   556,   564,   588,   610,   612,   615,   617,   623,   625,
   638,   642,   657,   663,   664,   667,   668,   671,   673,   677,
   681,   684,   689,   696,   697,   708,   710,   714,   716,   720,
   722,   726,   733,   742,   743,   746,   751,   755,   758,   759,
   762,   763,   764,   765,   766,   767,   768,   771,   772,   780,
   781,   784,   786,   806,   822,   829,   840,   848,   856,   861,
   869,   876,   878,   882,   884,   886,   899,   900,   903,   904,
   906,   908,   909,   912,   913,   916,   924,   927,   934,   937,
   945,   961,   963,   964,   967,   969,   973,   974,   977,   980,
   981,   984,   987,   990,   993,   996,   999,  1002,  1005,  1008,
  1011,  1014,  1017,  1020,  1023,  1026,  1029,  1032,  1035,  1036,
  1039,  1040,  1041,  1042,  1043,  1044,  1045,  1046,  1047,  1048,
  1049,  1052,  1053,  1054,  1055,  1056,  1057,  1058,  1059,  1060,
  1061,  1062,  1063,  1064,  1065,  1066,  1067,  1068,  1069,  1070,
  1071,  1074,  1075,  1076,  1077,  1078,  1079,  1080,  1081,  1082,
  1083,  1084,  1085,  1086,  1087,  1088,  1089,  1090,  1091,  1092,
  1093
};
#endif


#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)

static const char * const yytname[] = {   "$","error","$undefined.","DEFINE",
"DOMAIN_TOKEN","PROBLEM","REQUIREMENTS","STRIPS","TYPING","NEGATIVE_PRECONDITIONS",
"DISJUNCTIVE_PRECONDITIONS","EQUALITY","EXISTENTIAL_PRECONDITIONS","UNIVERSAL_PRECONDITIONS",
"QUANTIFIED_PRECONDITIONS","CONDITIONAL_EFFECTS","FLUENTS","ADL","DURATIVE_ACTIONS",
"DURATION_INEQUALITIES","CONTINUOUS_EFFECTS","TYPES","CONSTANTS","PREDICATES",
"ACTION","DURATIVE_ACTION","DURATION","PARAMETERS","PRECONDITION","CONDITION",
"EFFECT","PDOMAIN","OBJECTS","INIT","GOAL","METRIC","WHEN","NOT","AND","OR",
"IMPLY","EXISTS","FORALL","EITHER","AT","OVER","START","END","ALL","MINIMIZE",
"MAXIMIZE","TOTAL_TIME","LE","GE","NAME","DURATION_VAR","VARIABLE","NUMBER",
"ILLEGAL_TOKEN","'('","')'","'='","'+'","'-'","'*'","'/'","pddl_file","@1","domain_or_problems",
"domain_or_problem","domain","@2","domain_body","domain_body2","domain_body3",
"domain_body4","domain_body5","action_defs","require_def","require_keys","require_key",
"types_def","@3","constants_def","@4","predicates_def","atomic_formula_skeletons",
"atomic_formula_skeleton","@5","action_def","@6","@7","action_body","action_body2",
"precondition","@8","effect","eff_formula","@9","@10","eff_formulas","one_eff_formula",
"term_literals","term_literal","da_body","da_body2","da_body3","duration_constraint",
"simple_duration_constraint","simple_duration_constraints","da_gd","timed_gds",
"timed_gd","@11","@12","@13","da_effect","@14","da_effects","timed_effect","@15",
"@16","problem","@17","@18","problem_body","problem_body2","problem_body3","object_decl",
"@19","init","@20","name_literals","name_literal","atomic_name_formula","@21",
"names","goals","goal_list","goal","@22","metric_spec","optimization","ground_f_exp",
"ground_f_exp_opt","formulas","formula","@23","@24","atomic_term_formula","@25",
"terms","name_map","typed_names","@26","opt_typed_names","name_seq","opt_variables",
"variables","@27","vars","@28","opt_vars","variable_seq","types","type_spec",
"type","define","when","not","and","or","imply","exists","forall","either","at",
"over","start","end","all","duration_var","variable","predicate","function_symbol",
"name", NULL
};
#endif

static const short yyr1[] = {     0,
    67,    66,    68,    68,    69,    69,    71,    70,    72,    72,
    72,    72,    73,    73,    73,    74,    74,    74,    75,    75,
    75,    76,    76,    76,    77,    77,    78,    79,    79,    80,
    80,    80,    80,    80,    80,    80,    80,    80,    80,    80,
    80,    80,    80,    82,    81,    84,    83,    85,    86,    86,
    88,    87,    90,    89,    91,    89,    92,    92,    93,    93,
    95,    94,    96,    97,    97,    98,    97,    99,    97,   100,
   100,   101,   101,   102,   102,   103,   103,   104,   105,   105,
   106,   106,   107,   107,   108,   108,   108,   109,   109,   110,
   110,   111,   111,   113,   112,   114,   112,   115,   112,   116,
   116,   117,   116,   116,   118,   118,   120,   119,   121,   119,
   123,   124,   122,   125,   125,   126,   126,   127,   127,   129,
   128,   131,   130,   132,   132,   133,   133,   135,   134,   136,
   136,   137,   137,   138,   138,   140,   139,   141,   142,   142,
   143,   143,   143,   143,   143,   143,   143,   144,   144,   145,
   145,   146,   146,   146,   146,   146,   146,   147,   146,   148,
   146,   150,   149,   151,   151,   151,   152,   152,   153,   154,
   153,   155,   155,   156,   156,   157,   157,   159,   158,   160,
   161,   160,   162,   162,   163,   163,   164,   164,   165,   166,
   166,   167,    70,   122,   168,   169,   170,   171,   172,   173,
   174,   175,   176,   177,   178,   179,   180,   181,   182,   182,
   183,   183,   183,   183,   183,   183,   183,   183,   183,   183,
   183,   184,   184,   184,   184,   184,   184,   184,   184,   184,
   184,   184,   184,   184,   184,   184,   184,   184,   184,   184,
   184,   185,   185,   185,   185,   185,   185,   185,   185,   185,
   185,   185,   185,   185,   185,   185,   185,   185,   185,   185,
   185
};

static const short yyr2[] = {     0,
     0,     2,     0,     2,     1,     1,     0,     9,     0,     1,
     2,     1,     1,     2,     1,     2,     3,     1,     1,     2,
     1,     1,     2,     1,     1,     2,     4,     1,     2,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     0,     5,     0,     5,     4,     1,     2,
     0,     5,     0,    10,     0,    10,     2,     1,     0,     1,
     0,     3,     2,     1,     4,     0,     8,     0,     6,     0,
     2,     1,     4,     0,     2,     1,     4,     3,     3,     1,
     0,     2,     1,     4,     5,     5,     5,     0,     2,     1,
     4,     0,     2,     0,     6,     0,     6,     0,     6,     1,
     4,     0,     8,     5,     0,     2,     0,     6,     0,     6,
     0,     0,    14,     2,     1,     2,     1,     2,     1,     0,
     5,     0,     5,     1,     2,     1,     4,     0,     5,     0,
     2,     2,     1,     1,     2,     0,     5,     5,     1,     1,
     5,     5,     5,     5,     1,     4,     1,     0,     1,     0,
     2,     1,     4,     4,     4,     4,     5,     0,     8,     0,
     8,     0,     5,     0,     2,     2,     0,     1,     1,     0,
     4,     0,     1,     1,     2,     0,     1,     0,     2,     1,
     0,     4,     0,     1,     1,     2,     1,     2,     2,     1,
     4,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1
};

static const short yydefact[] = {     1,
     3,     2,   193,   194,     0,     4,     5,     6,   192,     0,
     0,     0,     0,   243,   244,   245,   246,   247,   248,   249,
   250,   251,   252,   253,   254,   255,   256,   257,   258,   259,
   260,   261,   242,     0,     0,     7,   111,     9,     0,     0,
     0,    12,    15,    18,    21,    24,    10,    13,    19,    22,
    25,     0,     0,    44,    46,     0,     0,     0,     8,     0,
    26,     0,    11,     0,    14,     0,    20,    22,     0,    23,
    16,     0,    30,    31,    32,    33,    34,    35,    36,    37,
    38,    39,    40,    41,    42,    43,     0,    28,   167,   167,
     0,     0,    49,    53,    55,    17,     0,    27,    29,     0,
   168,   169,   174,     0,   212,   213,   214,   215,   216,   217,
   218,   219,   220,   221,   211,    51,    48,    50,     0,     0,
   112,    45,     0,   170,   175,    47,   178,     0,     0,     0,
     0,   189,   190,   172,     0,   177,     0,   178,   178,     0,
     0,     0,   115,   117,     0,     0,   119,   133,   134,   202,
     0,   173,   171,    52,   209,   210,   179,   180,   185,     0,
     0,   120,   122,   136,     0,   114,   113,     0,   116,     0,
   118,     0,   135,   132,     0,   187,   181,   186,    59,     0,
   167,     0,     0,     0,   191,   188,   183,    61,     0,     0,
    58,    59,    60,     0,     0,     0,     0,     0,   124,   126,
     0,     0,   152,   139,   140,     0,   184,   182,     0,     0,
    63,    64,    76,    54,    57,     0,    81,    83,    56,   121,
   196,     0,   128,   123,   125,   197,   198,   199,   200,   201,
   164,     0,   150,   150,     0,   158,   160,   162,   137,   223,
   224,   225,   226,   227,   228,   229,   230,   231,   232,   233,
   234,   235,   236,   237,   238,   239,   240,   241,   222,   145,
     0,     0,   147,    62,   195,    68,     0,    70,    66,     0,
     0,     0,    88,     0,     0,    78,    80,     0,     0,   130,
     0,     0,     0,     0,     0,     0,     0,   164,     0,     0,
     0,     0,   130,   138,     0,     0,     0,     0,     0,   208,
     0,     0,     0,     0,     0,    81,    90,     0,    82,   100,
   127,     0,   153,   166,   165,   154,   155,   151,   156,     0,
   178,   178,     0,     0,   148,     0,     0,     0,     0,    77,
    65,    71,   178,     0,     0,     0,     0,    84,    89,   203,
   204,    92,     0,     0,    79,     0,   105,   102,     0,   129,
   131,   157,     0,     0,   163,     0,   149,     0,     0,     0,
   146,     0,     0,    72,     0,    85,    86,    87,     0,   205,
   206,    94,    96,   207,    98,     0,     0,     0,   107,   109,
     0,     0,   141,   142,   143,   144,    74,    69,     0,     0,
    91,    93,     0,     0,     0,     0,     0,   101,   106,   178,
     0,     0,     0,     0,     0,     0,     0,     0,     0,   104,
     0,     0,     0,   159,   161,     0,    73,    75,    67,    95,
    97,    99,     0,   108,   110,     0,   103,     0,     0,     0
};

static const short yydefgoto[] = {   428,
     1,     2,     6,     7,    38,    41,    42,    43,    44,    45,
    46,    47,    87,    88,    48,    89,    49,    90,    50,    92,
    93,   127,    51,   119,   120,   190,   191,   192,   209,   193,
   211,   299,   295,   298,   363,   405,   212,   195,   276,   277,
   217,   218,   304,   306,   369,   307,   393,   394,   395,   309,
   378,   377,   310,   401,   402,     8,    39,   130,   142,   143,
   144,   145,   181,   146,   182,   198,   199,   200,   280,   312,
   147,   148,   149,   183,   174,   206,   262,   358,   283,   318,
   286,   287,   203,   288,   281,   100,   101,   134,   153,   102,
   135,   136,   137,   157,   187,   208,   158,   175,   124,   132,
    10,   266,   267,   233,   234,   235,   236,   237,   151,   343,
   344,   372,   373,   375,   301,   159,   238,   263,   103
};

static const short yypact[] = {-32768,
-32768,    24,-32768,-32768,    19,-32768,-32768,-32768,-32768,   -23,
    24,   444,   444,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,   -17,    -9,-32768,-32768,   -11,    26,   166,
    44,-32768,-32768,-32768,-32768,    59,    77,    89,    97,    99,
-32768,   138,   572,-32768,-32768,   125,   444,   444,-32768,    98,
-32768,   156,-32768,   103,-32768,    85,-32768,    59,   128,    59,
    59,   444,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,   459,-32768,   444,   444,
   458,    86,-32768,-32768,-32768,    59,   115,-32768,-32768,   136,
-32768,   190,-32768,   165,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   182,   194,
-32768,-32768,   406,-32768,-32768,-32768,   192,   201,   202,   203,
   220,-32768,-32768,   444,   205,-32768,   112,   192,   192,     8,
   207,   208,-32768,-32768,   211,   212,-32768,   213,-32768,-32768,
   458,-32768,-32768,-32768,-32768,-32768,-32768,    -6,-32768,   214,
   215,-32768,-32768,-32768,    83,-32768,-32768,   140,-32768,   233,
-32768,   148,-32768,-32768,   116,-32768,-32768,-32768,    -3,   247,
   444,   217,   218,   149,-32768,-32768,   112,-32768,   235,   239,
-32768,   265,-32768,   248,   241,   246,   524,   141,-32768,-32768,
    93,   249,-32768,-32768,-32768,   379,-32768,-32768,   218,   496,
-32768,-32768,-32768,-32768,-32768,   -22,   173,-32768,-32768,-32768,
-32768,   251,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   218,-32768,-32768,   218,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
    30,   252,-32768,-32768,-32768,-32768,   254,-32768,-32768,   253,
   253,   253,-32768,   255,   256,-32768,-32768,   458,   257,-32768,
   242,   258,   146,   153,   218,   260,   261,-32768,   379,   379,
   379,   379,-32768,-32768,   218,   458,   262,   155,   264,-32768,
   267,   268,   269,   159,    14,   291,-32768,   113,-32768,-32768,
-32768,   325,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   271,
   192,   192,   300,   379,   379,   379,   379,   354,   273,-32768,
-32768,-32768,   192,   274,   275,   292,   -29,-32768,-32768,-32768,
-32768,-32768,   161,   279,-32768,   255,-32768,-32768,   161,-32768,
-32768,-32768,   293,   317,-32768,   318,-32768,   320,   321,   326,
-32768,   510,   327,-32768,   328,-32768,-32768,-32768,   183,-32768,
-32768,-32768,-32768,-32768,-32768,   330,   189,   347,-32768,-32768,
   218,   218,-32768,-32768,-32768,-32768,-32768,-32768,   235,   206,
-32768,-32768,   218,   218,   218,   289,   352,-32768,-32768,   192,
   273,   273,   353,   371,   195,   372,   374,   375,   377,-32768,
   380,   381,   382,-32768,-32768,   524,-32768,-32768,-32768,-32768,
-32768,-32768,   256,-32768,-32768,   383,-32768,   407,   439,-32768
};

static const short yypgoto[] = {-32768,
-32768,-32768,-32768,   433,-32768,-32768,   398,   409,-32768,   397,
   -24,   329,-32768,   410,-32768,-32768,   408,-32768,   415,-32768,
   404,-32768,    16,-32768,-32768,-32768,   319,-32768,-32768,-32768,
  -289,-32768,-32768,-32768,  -145,-32768,  -314,-32768,-32768,   204,
-32768,   216,-32768,   163,-32768,   147,-32768,-32768,-32768,  -360,
-32768,-32768,   142,-32768,-32768,   506,-32768,-32768,-32768,   384,
   376,-32768,-32768,-32768,-32768,-32768,   324,   301,-32768,   231,
   385,-32768,   378,-32768,-32768,-32768,  -271,-32768,   296,  -171,
-32768,-32768,  -185,-32768,   263,   -80,   401,-32768,-32768,-32768,
  -136,-32768,-32768,   349,-32768,-32768,-32768,-32768,   391,-32768,
-32768,   229,   -94,  -203,-32768,-32768,-32768,  -202,-32768,  -297,
-32768,   226,   227,-32768,   -13,  -152,   -86,   278,   -12
};


#define	YYLAST		592


static const short yytable[] = {    34,
    35,   160,   161,   213,   116,   178,   268,   269,   332,   104,
   349,   202,   273,    53,   364,   226,   399,   324,   325,   326,
   327,     9,   270,   271,   188,    70,   189,     3,     4,   270,
   271,   272,   240,   241,   242,    11,   133,   264,   272,   162,
   163,   164,    36,    70,    94,    95,    96,    40,   155,   156,
    37,   226,   356,   357,   359,   360,   123,   340,   341,    97,
   282,    61,   426,   285,   176,   243,   244,   245,   246,   247,
   248,   249,   250,   251,   252,   253,   254,   255,   256,   257,
   258,   297,     5,   259,    52,    61,   364,   364,   186,   125,
   418,   289,   290,   291,   292,   105,   106,   107,   349,   406,
   196,   342,   222,    59,   347,   348,   232,    56,    57,    58,
   223,    61,   213,   320,   162,   163,   164,    60,   105,   106,
   107,    57,    58,   329,    55,    56,    57,    58,   314,   221,
   226,   227,   228,   229,   230,    62,   108,   109,   110,   111,
   112,   113,   114,   213,    91,   117,   115,    64,   265,    55,
   226,    57,    58,   231,   230,    66,   340,    69,   387,   108,
   109,   110,   111,   112,   113,   114,   155,   156,    72,   115,
   314,    53,   163,   164,   121,   185,    54,    55,    56,    57,
    58,   164,   184,    91,   353,   354,    54,    55,    56,    57,
    58,   223,    14,    15,    16,   122,   365,   204,   205,   197,
   224,   274,   275,   213,   201,   317,   370,   371,   128,   403,
   404,   201,   319,   210,   331,   213,   213,   337,   338,   213,
   129,   407,   408,   409,   126,    17,    18,    19,    20,    21,
    22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
    32,   390,   391,    33,    14,    15,    16,   308,   398,   340,
   341,  -176,   123,   416,   417,   412,   413,   302,   303,   138,
   139,   140,   150,   411,   154,   165,   164,   167,   315,   168,
   170,   172,   194,   179,   180,   197,   201,    17,    18,    19,
    20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
    30,    31,    32,   210,   189,    33,   155,   156,   214,   351,
   219,   313,    14,    15,    16,   220,   216,   300,   239,   278,
   315,   294,   296,   305,   308,   351,   311,   316,   321,   322,
   275,   330,   333,   334,   335,   336,   374,    14,    15,    16,
   352,   362,   340,   366,   367,    17,    18,    19,    20,    21,
    22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
    32,   368,   381,    33,   155,   156,    14,    15,    16,   355,
    17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
    27,    28,    29,    30,    31,    32,   382,   383,    33,   384,
   385,   240,   241,   242,   350,   386,   388,   389,   396,    17,
    18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
    28,    29,    30,    31,    32,   400,   429,    33,   105,   106,
   107,   410,   414,   361,   243,   244,   245,   246,   247,   248,
   249,   250,   251,   252,   253,   254,   255,   256,   257,   258,
   415,   419,   259,   420,   421,   260,   422,   261,   430,   423,
   424,   425,   427,    12,    63,    67,    14,    15,    16,   108,
   109,   110,   111,   112,   113,   114,    65,    71,   141,   115,
   105,   106,   107,    68,   131,    73,    74,    75,    76,    77,
    78,    79,    80,    81,    82,    83,    84,    85,    86,    17,
    18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
    28,    29,    30,    31,    32,   118,    99,    33,   105,   106,
   107,   108,   109,   110,   111,   112,   113,   114,   376,   345,
   215,   115,   105,   106,   107,   392,    13,   397,    98,   339,
   169,   225,   279,   328,   166,   173,   105,   106,   107,   284,
   171,   265,   221,   226,   152,   207,   346,   230,   293,   108,
   109,   110,   111,   112,   113,   114,   221,   226,   177,   115,
   323,     0,     0,   108,   109,   110,   111,   112,   113,   114,
   221,     0,     0,   115,     0,     0,     0,   108,   109,   110,
   111,   112,   113,   114,   379,   380,     0,   115,    73,    74,
    75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
    85,    86
};

static const short yycheck[] = {    12,
    13,   138,   139,   189,    91,   158,   210,   210,   298,    90,
   308,   183,   216,     6,   329,    38,   377,   289,   290,   291,
   292,     3,    52,    53,    28,    50,    30,     4,     5,    52,
    53,    61,     3,     4,     5,    59,   123,   209,    61,    32,
    33,    34,    60,    68,    57,    58,    71,    59,    55,    56,
    60,    38,   324,   325,   326,   327,    63,    44,    45,    72,
   232,    46,   423,   235,   151,    36,    37,    38,    39,    40,
    41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
    51,   267,    59,    54,    59,    70,   401,   402,   175,   102,
   405,    62,    63,    64,    65,     3,     4,     5,   396,   389,
   181,   305,   197,    60,   308,   308,   201,    23,    24,    25,
   197,    96,   298,   285,    32,    33,    34,    59,     3,     4,
     5,    24,    25,   295,    22,    23,    24,    25,   281,    37,
    38,    39,    40,    41,    42,    59,    44,    45,    46,    47,
    48,    49,    50,   329,    59,    60,    54,    59,    36,    22,
    38,    24,    25,    61,    42,    59,    44,    59,   362,    44,
    45,    46,    47,    48,    49,    50,    55,    56,    31,    54,
   323,     6,    33,    34,    60,    60,    21,    22,    23,    24,
    25,    34,    35,    59,   321,   322,    21,    22,    23,    24,
    25,   278,     3,     4,     5,    60,   333,    49,    50,    59,
    60,    29,    30,   389,    59,    60,    46,    47,    27,   381,
   382,    59,    60,    59,    60,   401,   402,    59,    60,   405,
    27,   393,   394,   395,    60,    36,    37,    38,    39,    40,
    41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
    51,    59,    60,    54,     3,     4,     5,    59,    60,    44,
    45,    60,    63,    59,    60,   401,   402,   271,   272,    59,
    59,    59,    43,   400,    60,    59,    34,    60,   281,    59,
    59,    59,    26,    60,    60,    59,    59,    36,    37,    38,
    39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
    49,    50,    51,    59,    30,    54,    55,    56,    60,   312,
    60,    60,     3,     4,     5,    60,    59,    55,    60,    59,
   323,    60,    59,    59,    59,   328,    60,    60,    59,    59,
    30,    60,    59,    57,    57,    57,    48,     3,     4,     5,
    60,    59,    44,    60,    60,    36,    37,    38,    39,    40,
    41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
    51,    60,    60,    54,    55,    56,     3,     4,     5,    60,
    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
    46,    47,    48,    49,    50,    51,    60,    60,    54,    60,
    60,     3,     4,     5,    60,    60,    60,    60,    59,    36,
    37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
    47,    48,    49,    50,    51,    59,     0,    54,     3,     4,
     5,    60,    60,    60,    36,    37,    38,    39,    40,    41,
    42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
    60,    60,    54,    60,    60,    57,    60,    59,     0,    60,
    60,    60,    60,    11,    47,    49,     3,     4,     5,    44,
    45,    46,    47,    48,    49,    50,    48,    50,   130,    54,
     3,     4,     5,    49,    59,     7,     8,     9,    10,    11,
    12,    13,    14,    15,    16,    17,    18,    19,    20,    36,
    37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
    47,    48,    49,    50,    51,    92,    87,    54,     3,     4,
     5,    44,    45,    46,    47,    48,    49,    50,   346,   306,
   192,    54,     3,     4,     5,   369,    11,   376,    60,   304,
   145,   198,   222,   293,   141,   148,     3,     4,     5,   234,
   146,    36,    37,    38,   134,   187,   308,    42,   261,    44,
    45,    46,    47,    48,    49,    50,    37,    38,   158,    54,
   288,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
    37,    -1,    -1,    54,    -1,    -1,    -1,    44,    45,    46,
    47,    48,    49,    50,   349,   349,    -1,    54,     7,     8,
     9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
    19,    20
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/lib/bison.simple"
/* This file comes from bison-1.28.  */

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

#ifndef YYSTACK_USE_ALLOCA
#ifdef alloca
#define YYSTACK_USE_ALLOCA
#else /* alloca not defined */
#ifdef __GNUC__
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
#define YYSTACK_USE_ALLOCA
#include <alloca.h>
#else /* not sparc */
/* We think this test detects Watcom and Microsoft C.  */
/* This used to test MSDOS, but that is a bad idea
   since that symbol is in the user namespace.  */
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
#if 0 /* No need for malloc.h, which pollutes the namespace;
	 instead, just don't use alloca.  */
#include <malloc.h>
#endif
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
/* I don't know what this was needed for, but it pollutes the namespace.
   So I turned it off.   rms, 2 May 1997.  */
/* #include <malloc.h>  */
 #pragma alloca
#define YYSTACK_USE_ALLOCA
#else /* not MSDOS, or __TURBOC__, or _AIX */
#if 0
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
		 and on HPUX 10.  Eventually we can turn this on.  */
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#endif /* __hpux */
#endif
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc */
#endif /* not GNU C */
#endif /* alloca not defined */
#endif /* YYSTACK_USE_ALLOCA not defined */

#ifdef YYSTACK_USE_ALLOCA
#define YYSTACK_ALLOC alloca
#else
#define YYSTACK_ALLOC malloc
#endif

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	goto yyacceptlab
#define YYABORT 	goto yyabortlab
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Define __yy_memcpy.  Note that the size argument
   should be passed with type unsigned int, because that is what the non-GCC
   definitions require.  With GCC, __builtin_memcpy takes an arg
   of type size_t, but it can handle unsigned int.  */

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (to, from, count)
     char *to;
     char *from;
     unsigned int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (char *to, char *from, unsigned int count)
{
  register char *t = to;
  register char *f = from;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 217 "/usr/lib/bison.simple"

/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
#ifdef __cplusplus
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
#ifdef YYPARSE_PARAM
int yyparse (void *);
#else
int yyparse (void);
#endif
#endif

int
yyparse(YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;
  int yyfree_stacks = 0;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack */
      /* Use copies of these so that the &'s don't force the real ones into memory. */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
      /* This used to be a conditional around just the two extra args,
	 but that might be undefined if yyoverflow is a macro.  */
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yyls1, size * sizeof (*yylsp),
		 &yystacksize);
#else
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yystacksize);
#endif

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  if (yyfree_stacks)
	    {
	      free (yyss);
	      free (yyvs);
#ifdef YYLSP_NEEDED
	      free (yyls);
#endif
	    }
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
#ifndef YYSTACK_USE_ALLOCA
      yyfree_stacks = 1;
#endif
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss, (char *)yyss1,
		   size * (unsigned int) sizeof (*yyssp));
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
		   size * (unsigned int) sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls, (char *)yyls1,
		   size * (unsigned int) sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise meaning
	     of a token, for further debugging info.  */
#ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
#endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
    yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 1:
#line 185 "pddl.yy"
{ line_number = 1; ;
    break;}
case 2:
#line 185 "pddl.yy"
{ if (!success) YYERROR; ;
    break;}
case 5:
#line 192 "pddl.yy"
{ context = ""; ;
    break;}
case 6:
#line 193 "pddl.yy"
{ context = ""; ;
    break;}
case 7:
#line 202 "pddl.yy"
{
	     pdomain = NULL;
	     domain = new Domain(*yyvsp[-1].str);
	     delete yyvsp[-1].str;
	     requirements = &domain->requirements;
	     context = " in domain `" + domain->name() + "'";
	     problem = NULL;
	   ;
    break;}
case 25:
#line 239 "pddl.yy"
{ add_action(*yyvsp[0].action); ;
    break;}
case 26:
#line 240 "pddl.yy"
{ add_action(*yyvsp[0].action); ;
    break;}
case 30:
#line 251 "pddl.yy"
{ requirements->strips = true; ;
    break;}
case 31:
#line 253 "pddl.yy"
{
		  requirements->typing = true;
		  domain->add_type(SimpleType::OBJECT);
		;
    break;}
case 32:
#line 258 "pddl.yy"
{ requirements->negative_preconditions = true; ;
    break;}
case 33:
#line 260 "pddl.yy"
{ requirements->disjunctive_preconditions = true; ;
    break;}
case 34:
#line 262 "pddl.yy"
{ requirements->equality = true; ;
    break;}
case 35:
#line 264 "pddl.yy"
{ requirements->existential_preconditions = true; ;
    break;}
case 36:
#line 266 "pddl.yy"
{ requirements->universal_preconditions = true; ;
    break;}
case 37:
#line 268 "pddl.yy"
{ requirements->quantified_preconditions(); ;
    break;}
case 38:
#line 270 "pddl.yy"
{ requirements->conditional_effects = true; ;
    break;}
case 39:
#line 272 "pddl.yy"
{ throw Unimplemented("`:fluents' not supported"); ;
    break;}
case 40:
#line 274 "pddl.yy"
{ requirements->adl(); ;
    break;}
case 41:
#line 276 "pddl.yy"
{ requirements->durative_actions = true; ;
    break;}
case 42:
#line 278 "pddl.yy"
{ requirements->duration_inequalities = true; ;
    break;}
case 43:
#line 280 "pddl.yy"
{ throw Unimplemented("`:continuous-effects' not supported"); ;
    break;}
case 44:
#line 284 "pddl.yy"
{
		if (!requirements->typing) {
		  domain->add_type(SimpleType::OBJECT);
		  yywarning("assuming `:typing' requirement");
		  requirements->typing = true;
		}
		name_map_type = TYPE_MAP;
	      ;
    break;}
case 46:
#line 296 "pddl.yy"
{
		    name_map_type = CONSTANT_MAP;
		  ;
    break;}
case 51:
#line 310 "pddl.yy"
{
			      predicate = new Predicate(*yyvsp[0].str);
			      delete yyvsp[0].str;
			    ;
    break;}
case 52:
#line 315 "pddl.yy"
{
			      add_predicate(*predicate);
			      predicate = NULL;
			    ;
    break;}
case 53:
#line 327 "pddl.yy"
{
		 context = (" in action `" + *yyvsp[0].str + "' of domain `"
			    + domain->name() + "'");
		 free_variables.push_frame();
	       ;
    break;}
case 54:
#line 333 "pddl.yy"
{
		 free_variables.pop_frame();
		 yyval.action =
		   new ActionSchema(*yyvsp[-7].str, *yyvsp[-3].variables, *action_precond,
				    action_effs->strengthen(*action_precond));
		 delete yyvsp[-7].str;
	       ;
    break;}
case 55:
#line 341 "pddl.yy"
{
		 if (!requirements->durative_actions) {
		   yywarning("assuming `:durative-actions' requirement");
		   requirements->durative_actions = true;
		 }
		 context = (" in action `" + *yyvsp[0].str + "' of domain `"
			    + domain->name() + "'");
		 free_variables.push_frame();
		 free_variables.insert(&DURATION_VARIABLE);
		 action_duration = make_pair(0.0f, INFINITY);
	       ;
    break;}
case 56:
#line 353 "pddl.yy"
{
		 free_variables.pop_frame();
		 yyval.action =
		   new ActionSchema(*yyvsp[-7].str, *yyvsp[-3].variables, *action_precond,
				    action_effs->strengthen(*action_precond),
				    action_duration.first,
				    action_duration.second);
		 delete yyvsp[-7].str;
	       ;
    break;}
case 57:
#line 364 "pddl.yy"
{ action_precond = yyvsp[-1].formula; ;
    break;}
case 58:
#line 365 "pddl.yy"
{action_precond = &Formula::TRUE; ;
    break;}
case 59:
#line 368 "pddl.yy"
{ action_effs = &EffectList::EMPTY; ;
    break;}
case 60:
#line 369 "pddl.yy"
{ action_effs = yyvsp[0].effects; ;
    break;}
case 61:
#line 372 "pddl.yy"
{ formula_time = Formula::OVER_ALL; ;
    break;}
case 62:
#line 373 "pddl.yy"
{ yyval.formula = yyvsp[0].formula; ;
    break;}
case 63:
#line 376 "pddl.yy"
{ yyval.effects = yyvsp[0].effects; ;
    break;}
case 64:
#line 380 "pddl.yy"
{
		  yyval.effects = new EffectList(new Effect(*yyvsp[0].add_del_lists->first, *yyvsp[0].add_del_lists->second,
						 Effect::AT_END));
		  delete yyvsp[0].add_del_lists;
		;
    break;}
case 65:
#line 386 "pddl.yy"
{ yyval.effects = yyvsp[-1].effects; ;
    break;}
case 66:
#line 388 "pddl.yy"
{
		  if (!requirements->conditional_effects) {
		    yywarning("assuming `:conditional-effects' requirement");
		    requirements->conditional_effects = true;
		  }
		  free_variables.push_frame();
		;
    break;}
case 67:
#line 396 "pddl.yy"
{
		  free_variables.pop_frame();
		  if (yyvsp[-3].variables->empty()) {
		    yyval.effects = yyvsp[-1].effects;
		  } else {
		    for (size_t i = 0; i < yyvsp[-1].effects->size(); i++) {
		      const Effect& e = *(*yyvsp[-1].effects)[i];
		      if (e.forall().empty()) {
			(*yyvsp[-1].effects)[i] = new Effect(*yyvsp[-3].variables, e.condition(),
					      e.add_list(), e.del_list(),
					      e.when());
		      } else {
			VariableList& forall = *(new VariableList(*yyvsp[-3].variables));
			copy(e.forall().begin(), e.forall().end(),
			     back_inserter(forall));
			(*yyvsp[-1].effects)[i] = new Effect(forall, e.condition(),
					      e.add_list(), e.del_list(),
					      e.when());
		      }
		    }
		    yyval.effects = yyvsp[-1].effects;
		  }
		;
    break;}
case 68:
#line 419 "pddl.yy"
{ formula_time = Formula::OVER_ALL; ;
    break;}
case 69:
#line 421 "pddl.yy"
{
		  if (!requirements->conditional_effects) {
		    yywarning("assuming `:conditional-effects' requirement");
		    requirements->conditional_effects = true;
		  }
		  if (yyvsp[-2].formula->tautology()) {
		    yyval.effects = new EffectList(new Effect(*yyvsp[-1].add_del_lists->first, *yyvsp[-1].add_del_lists->second,
						   Effect::AT_END));
		  } else if (yyvsp[-2].formula->contradiction()) {
		    yyval.effects = new EffectList();
		  } else {
		    yyval.effects = new EffectList(new Effect(*yyvsp[-2].formula,
						   *yyvsp[-1].add_del_lists->first, *yyvsp[-1].add_del_lists->second,
						   Effect::AT_END));
		  }
		  delete yyvsp[-1].add_del_lists;
		;
    break;}
case 70:
#line 441 "pddl.yy"
{ yyval.effects = new EffectList(); ;
    break;}
case 71:
#line 443 "pddl.yy"
{ copy(yyvsp[0].effects->begin(), yyvsp[0].effects->end(), back_inserter(*yyvsp[-1].effects)); yyval.effects = yyvsp[-1].effects; ;
    break;}
case 73:
#line 447 "pddl.yy"
{ yyval.add_del_lists = yyvsp[-1].add_del_lists; ;
    break;}
case 74:
#line 451 "pddl.yy"
{ yyval.add_del_lists = &make_add_del(new AtomList(), new NegationList()); ;
    break;}
case 75:
#line 453 "pddl.yy"
{
		    copy(yyvsp[0].add_del_lists->first->begin(), yyvsp[0].add_del_lists->first->end(),
			 back_inserter(*yyvsp[-1].add_del_lists->first));
		    copy(yyvsp[0].add_del_lists->second->begin(), yyvsp[0].add_del_lists->second->end(),
			 back_inserter(*yyvsp[-1].add_del_lists->second));
		    yyval.add_del_lists = yyvsp[-1].add_del_lists;
		    delete yyvsp[0].add_del_lists;
		  ;
    break;}
case 76:
#line 464 "pddl.yy"
{ yyval.add_del_lists = &make_add_del(new AtomList(yyvsp[0].atom), new NegationList()); ;
    break;}
case 77:
#line 466 "pddl.yy"
{ yyval.add_del_lists = &make_add_del(new AtomList(), new NegationList(yyvsp[-1].atom)); ;
    break;}
case 79:
#line 472 "pddl.yy"
{ action_precond = yyvsp[-1].formula; ;
    break;}
case 80:
#line 473 "pddl.yy"
{ action_precond = &Formula::TRUE; ;
    break;}
case 81:
#line 476 "pddl.yy"
{ action_effs = &EffectList::EMPTY; ;
    break;}
case 82:
#line 477 "pddl.yy"
{ action_effs = yyvsp[0].effects; ;
    break;}
case 84:
#line 482 "pddl.yy"
{
			  if (!requirements->duration_inequalities) {
			    yywarning("assuming `:duration-inequalities' "
				      "requirement");
			    requirements->duration_inequalities = true;
			  }
			;
    break;}
case 85:
#line 492 "pddl.yy"
{
				 if (!requirements->duration_inequalities) {
				   yywarning("assuming "
					     "`:duration-inequalities' "
					     "requirement");
				   requirements->duration_inequalities = true;
				 }
				 if (yyvsp[-1].num < action_duration.second) {
				   action_duration.second = yyvsp[-1].num;
				 }
			       ;
    break;}
case 86:
#line 504 "pddl.yy"
{
				 if (!requirements->duration_inequalities) {
				   yywarning("assuming "
					     "`:duration-inequalities' "
					     "requirement");
				   requirements->duration_inequalities = true;
				 }
				 if (action_duration.first < yyvsp[-1].num) {
				   action_duration.first = yyvsp[-1].num;
				 }
			       ;
    break;}
case 87:
#line 516 "pddl.yy"
{
				 if (action_duration.first <= yyvsp[-1].num
				     && yyvsp[-1].num <= action_duration.second) {
				   action_duration.first =
				     action_duration.second = yyvsp[-1].num;
				 } else {
				   action_duration = make_pair(1.0f, -1.0f);
				 }
			       ;
    break;}
case 91:
#line 533 "pddl.yy"
{
	    yyval.formula = &Formula::TRUE;
	    for (FormulaListIter fi = yyvsp[-1].formulas->begin(); fi != yyvsp[-1].formulas->end(); fi++) {
	      yyval.formula = &(*yyval.formula && **fi);
	    }
	  ;
    break;}
case 92:
#line 541 "pddl.yy"
{ yyval.formulas = new FormulaList(); ;
    break;}
case 93:
#line 542 "pddl.yy"
{ yyvsp[-1].formulas->push_back(yyvsp[0].formula); yyval.formulas = yyvsp[-1].formulas; ;
    break;}
case 94:
#line 545 "pddl.yy"
{ formula_time = Formula::AT_START; ;
    break;}
case 95:
#line 546 "pddl.yy"
{ yyval.formula = yyvsp[-1].formula; ;
    break;}
case 96:
#line 547 "pddl.yy"
{ formula_time = Formula::AT_END; ;
    break;}
case 97:
#line 548 "pddl.yy"
{ yyval.formula = yyvsp[-1].formula; ;
    break;}
case 98:
#line 549 "pddl.yy"
{ formula_time = Formula::OVER_ALL; ;
    break;}
case 99:
#line 550 "pddl.yy"
{ yyval.formula = yyvsp[-1].formula; ;
    break;}
case 101:
#line 555 "pddl.yy"
{ yyval.effects = yyvsp[-1].effects; ;
    break;}
case 102:
#line 557 "pddl.yy"
{
		if (!requirements->conditional_effects) {
		  yywarning("assuming `:conditional-effects' requirement");
		  requirements->conditional_effects = true;
		}
		free_variables.push_frame();
	      ;
    break;}
case 103:
#line 565 "pddl.yy"
{
		free_variables.pop_frame();
		if (yyvsp[-3].variables->empty()) {
		  yyval.effects = yyvsp[-1].effects;
		} else {
		  for (size_t i = 0; i < yyvsp[-1].effects->size(); i++) {
		    const Effect& e = *(*yyvsp[-1].effects)[i];
		    if (e.forall().empty()) {
		      (*yyvsp[-1].effects)[i] = new Effect(*yyvsp[-3].variables, e.condition(),
					    e.add_list(), e.del_list(),
					    e.when());
		    } else {
		      VariableList& forall = *(new VariableList(*yyvsp[-3].variables));
		      copy(e.forall().begin(), e.forall().end(),
			   back_inserter(forall));
		      (*yyvsp[-1].effects)[i] = new Effect(forall, e.condition(),
					    e.add_list(), e.del_list(),
					    e.when());
		    }
		  }
		  yyval.effects = yyvsp[-1].effects;
		}
	      ;
    break;}
case 104:
#line 589 "pddl.yy"
{
		if (!requirements->conditional_effects) {
		  yywarning("assuming `:conditional-effects' requirement");
		  requirements->conditional_effects = true;
		}
		if (yyvsp[-2].formula->tautology()) {
		  yyval.effects = yyvsp[-1].effects;
		} else if (yyvsp[-2].formula->contradiction()) {
		  yyval.effects = new EffectList();
		} else {
		  for (size_t i = 0; i < yyvsp[-1].effects->size(); i++) {
		    const Effect& e = *(*yyvsp[-1].effects)[i];
		    (*yyvsp[-1].effects)[i] = new Effect(e.forall(), *yyvsp[-2].formula,
					  e.add_list(), e.del_list(),
					  e.when());
		  }
		  yyval.effects = yyvsp[-1].effects;
		}
	      ;
    break;}
case 105:
#line 611 "pddl.yy"
{ yyval.effects = new EffectList(); ;
    break;}
case 106:
#line 613 "pddl.yy"
{ copy(yyvsp[0].effects->begin(), yyvsp[0].effects->end(), back_inserter(*yyvsp[-1].effects)); yyval.effects = yyvsp[-1].effects; ;
    break;}
case 107:
#line 616 "pddl.yy"
{ formula_time = Formula::AT_START; ;
    break;}
case 108:
#line 618 "pddl.yy"
{
		   yyval.effects = new EffectList(new Effect(*yyvsp[-1].add_del_lists->first, *yyvsp[-1].add_del_lists->second,
						  Effect::AT_START));
		   delete yyvsp[-1].add_del_lists;
		 ;
    break;}
case 109:
#line 624 "pddl.yy"
{ formula_time = Formula::AT_END; ;
    break;}
case 110:
#line 626 "pddl.yy"
{
		   yyval.effects = new EffectList(new Effect(*yyvsp[-1].add_del_lists->first, *yyvsp[-1].add_del_lists->second,
						  Effect::AT_END));
		   delete yyvsp[-1].add_del_lists;
		 ;
    break;}
case 111:
#line 639 "pddl.yy"
{
	      context = " in problem `" + *yyvsp[-1].str + "'";
	    ;
    break;}
case 112:
#line 643 "pddl.yy"
{
	      domain = NULL;
	      pdomain = Domain::find(*yyvsp[-1].str);
	      delete yyvsp[-1].str;
	      if (pdomain != NULL) {
		requirements = new Requirements(pdomain->requirements);
	      } else {
		yyerror("undeclared domain used");
		/* Cannot recover from this error, so just bail out. */
		YYERROR;
	      }
	      problem = new Problem(*yyvsp[-6].str, *pdomain);
	      delete yyvsp[-6].str;
	    ;
    break;}
case 113:
#line 658 "pddl.yy"
{
	      delete requirements;
	    ;
    break;}
case 118:
#line 672 "pddl.yy"
{ problem->set_init(*yyvsp[-1].effect); problem->set_goal(*yyvsp[0].formula); ;
    break;}
case 119:
#line 674 "pddl.yy"
{ problem->set_goal(*yyvsp[0].formula); ;
    break;}
case 120:
#line 678 "pddl.yy"
{
		  name_map_type = OBJECT_MAP;
		;
    break;}
case 122:
#line 685 "pddl.yy"
{
	   context =
	     " in initial conditions of problem `" + problem->name() + "'";
	 ;
    break;}
case 123:
#line 690 "pddl.yy"
{
	   yyval.effect = new Effect(*yyvsp[-1].add_del_lists->first, *yyvsp[-1].add_del_lists->second, Effect::AT_END);
	   delete yyvsp[-1].add_del_lists;
	 ;
    break;}
case 125:
#line 698 "pddl.yy"
{
		    copy(yyvsp[0].add_del_lists->first->begin(), yyvsp[0].add_del_lists->first->end(),
			 back_inserter(*yyvsp[-1].add_del_lists->first));
		    copy(yyvsp[0].add_del_lists->second->begin(), yyvsp[0].add_del_lists->second->end(),
			 back_inserter(*yyvsp[-1].add_del_lists->second));
		    yyval.add_del_lists = yyvsp[-1].add_del_lists;
		    delete yyvsp[0].add_del_lists;
		  ;
    break;}
case 126:
#line 709 "pddl.yy"
{ yyval.add_del_lists = &make_add_del(new AtomList(yyvsp[0].atom), new NegationList()); ;
    break;}
case 127:
#line 711 "pddl.yy"
{ yyval.add_del_lists = &make_add_del(new AtomList(), new NegationList()); ;
    break;}
case 128:
#line 715 "pddl.yy"
{ current_predicate = *yyvsp[0].str; ;
    break;}
case 129:
#line 717 "pddl.yy"
{ yyval.atom = &make_atom(*yyvsp[-3].str, *yyvsp[-1].terms); delete yyvsp[-3].str; ;
    break;}
case 130:
#line 721 "pddl.yy"
{ yyval.terms = new TermList(); ;
    break;}
case 131:
#line 723 "pddl.yy"
{ yyval.terms = &add_name(*yyvsp[-1].terms, *yyvsp[0].str); delete yyvsp[0].str; ;
    break;}
case 132:
#line 727 "pddl.yy"
{
	    yyval.formula = &Formula::TRUE;
	    for (FormulaListIter fi = yyvsp[-1].formulas->begin(); fi != yyvsp[-1].formulas->end(); fi++) {
	      yyval.formula = &(*yyval.formula && **fi);
	    }
	  ;
    break;}
case 133:
#line 734 "pddl.yy"
{
	    yyval.formula = &Formula::TRUE;
	    for (FormulaListIter fi = yyvsp[0].formulas->begin(); fi != yyvsp[0].formulas->end(); fi++) {
	      yyval.formula = &(*yyval.formula && **fi);
	    }
	  ;
    break;}
case 134:
#line 742 "pddl.yy"
{ yyval.formulas = new FormulaList(yyvsp[0].formula); ;
    break;}
case 135:
#line 743 "pddl.yy"
{ yyvsp[-1].formulas->push_back(yyvsp[0].formula); yyval.formulas = yyvsp[-1].formulas; ;
    break;}
case 136:
#line 747 "pddl.yy"
{
	   context = " in goal of problem `" + problem->name() + "'";
	   formula_time = Formula::AT_START;
	 ;
    break;}
case 137:
#line 752 "pddl.yy"
{ yyval.formula = yyvsp[-1].formula; ;
    break;}
case 139:
#line 758 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 140:
#line 759 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 145:
#line 766 "pddl.yy"
{;
    break;}
case 146:
#line 767 "pddl.yy"
{ delete yyvsp[-2].str; ;
    break;}
case 147:
#line 768 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 150:
#line 780 "pddl.yy"
{ yyval.formulas = new FormulaList(); ;
    break;}
case 151:
#line 781 "pddl.yy"
{ yyvsp[-1].formulas->push_back(yyvsp[0].formula); yyval.formulas = yyvsp[-1].formulas; ;
    break;}
case 152:
#line 785 "pddl.yy"
{ yyval.formula = yyvsp[0].atom ;
    break;}
case 153:
#line 787 "pddl.yy"
{
	      if (!requirements->equality) {
		yywarning("assuming `:equality' requirement");
		requirements->equality = true;
	      }
	      if (yyvsp[-1].terms->size() != 2) {
		yyerror(tostring(yyvsp[-1].terms->size()) + " parameter"
			+ string((yyvsp[-1].terms->size() == 1) ? "" : "s")
			+ " passed to predicate `=' expecting 2");
	      }
	      const Term& t1 = *(*yyvsp[-1].terms)[0];
	      const Term& t2 = *(*yyvsp[-1].terms)[1];
	      if (t1.type().subtype(t2.type())
		  || t2.type().subtype(t1.type())) {
		yyval.formula = new Equality(t1, t2);
	      } else {
		yyval.formula = &Formula::FALSE;
	      }
	    ;
    break;}
case 154:
#line 807 "pddl.yy"
{
	      if (typeid(*yyvsp[-1].formula) == typeid(Atom)) {
		if (!requirements->negative_preconditions) {
		  yywarning("assuming `:negative-preconditions' "
			    "requirement");
		  requirements->negative_preconditions = true;
		}
	      } else if (!requirements->disjunctive_preconditions
			 && typeid(*yyvsp[-1].formula) != typeid(Equality)) {
		yywarning("assuming `:disjunctive-preconditions' "
			  "requirement");
		requirements->disjunctive_preconditions = true;
	      }
	      yyval.formula = &!*yyvsp[-1].formula;
	    ;
    break;}
case 155:
#line 823 "pddl.yy"
{
	      yyval.formula = &Formula::TRUE;
	      for (FormulaListIter fi = yyvsp[-1].formulas->begin(); fi != yyvsp[-1].formulas->end(); fi++) {
		yyval.formula = &(*yyval.formula && **fi);
	      }
	    ;
    break;}
case 156:
#line 830 "pddl.yy"
{
	      if (!requirements->disjunctive_preconditions) {
		yywarning("assuming `:disjunctive-preconditions' requirement");
		requirements->disjunctive_preconditions = true;
	      }
	      yyval.formula = &Formula::FALSE;
	      for (FormulaListIter fi = yyvsp[-1].formulas->begin(); fi != yyvsp[-1].formulas->end(); fi++) {
		yyval.formula = &(*yyval.formula || **fi);
	      }
	    ;
    break;}
case 157:
#line 841 "pddl.yy"
{
	      if (!requirements->disjunctive_preconditions) {
		yywarning("assuming `:disjunctive-preconditions' requirement");
		requirements->disjunctive_preconditions = true;
	      }
	      yyval.formula = &(!*yyvsp[-2].formula || *yyvsp[-1].formula);
	    ;
    break;}
case 158:
#line 849 "pddl.yy"
{
	      if (!requirements->existential_preconditions) {
		yywarning("assuming `:existential-preconditions' requirement");
		requirements->existential_preconditions = true;
	      }
	      free_variables.push_frame();
	    ;
    break;}
case 159:
#line 857 "pddl.yy"
{
	      free_variables.pop_frame();
	      yyval.formula = yyvsp[-3].variables->empty() ? yyvsp[-1].formula : new ExistsFormula(*yyvsp[-3].variables, *yyvsp[-1].formula);
	    ;
    break;}
case 160:
#line 862 "pddl.yy"
{
	      if (!requirements->universal_preconditions) {
		yywarning("assuming `:universal-preconditions' requirement");
		requirements->universal_preconditions = true;
	      }
	      free_variables.push_frame();
	    ;
    break;}
case 161:
#line 870 "pddl.yy"
{
	      free_variables.pop_frame();
	      yyval.formula = yyvsp[-3].variables->empty() ? yyvsp[-1].formula : new ForallFormula(*yyvsp[-3].variables, *yyvsp[-1].formula);
	    ;
    break;}
case 162:
#line 877 "pddl.yy"
{ current_predicate = *yyvsp[0].str; ;
    break;}
case 163:
#line 879 "pddl.yy"
{ yyval.atom = &make_atom(*yyvsp[-3].str, *yyvsp[-1].terms); delete yyvsp[-3].str; ;
    break;}
case 164:
#line 883 "pddl.yy"
{ yyval.terms = new TermList(); ;
    break;}
case 165:
#line 885 "pddl.yy"
{ yyval.terms = &add_name(*yyvsp[-1].terms, *yyvsp[0].str); delete yyvsp[0].str; ;
    break;}
case 166:
#line 887 "pddl.yy"
{
	    const Variable* v = free_variables.find(*yyvsp[0].str);
	    if (v == NULL) {
	      yyerror("free variable `" + *yyvsp[0].str + "'");
	      v = new Variable(*yyvsp[0].str, SimpleType::OBJECT);
	    }
	    yyvsp[-1].terms->push_back(v);
	    yyval.terms = yyvsp[-1].terms;
	    delete yyvsp[0].str;
	  ;
    break;}
case 169:
#line 903 "pddl.yy"
{ add_names(*yyvsp[0].strings); delete yyvsp[0].strings; ;
    break;}
case 170:
#line 904 "pddl.yy"
{ add_names(*yyvsp[-1].strings, *yyvsp[0].type); delete yyvsp[-1].strings; ;
    break;}
case 174:
#line 912 "pddl.yy"
{ yyval.strings = new vector<string>(1, *yyvsp[0].str); delete yyvsp[0].str; ;
    break;}
case 175:
#line 913 "pddl.yy"
{ yyvsp[-1].strings->push_back(*yyvsp[0].str); yyval.strings = yyvsp[-1].strings; delete yyvsp[0].str; ;
    break;}
case 176:
#line 917 "pddl.yy"
{
		    if (predicate == NULL) {
		      yyval.variables = new VariableList();
		    } else {
		      yyval.variables = NULL;
		    }
		  ;
    break;}
case 178:
#line 927 "pddl.yy"
{
              if (predicate == NULL) {
		variables = new VariableList();
	      } else {
		variables = NULL;
	      }
            ;
    break;}
case 179:
#line 934 "pddl.yy"
{ yyval.variables = variables; ;
    break;}
case 180:
#line 938 "pddl.yy"
{
	   for (vector<string>::const_iterator si = yyvsp[0].strings->begin();
		si != yyvsp[0].strings->end(); si++) {
	     add_variable(*si);
	   }
	   delete yyvsp[0].strings;
	 ;
    break;}
case 181:
#line 946 "pddl.yy"
{
	   const UnionType* ut = dynamic_cast<const UnionType*>(yyvsp[0].type);
	   for (vector<string>::const_iterator si = yyvsp[-1].strings->begin();
		si != yyvsp[-1].strings->end(); si++) {
	     /* Duplicate type if it is a union type so that every
		variable has its own copy. */
	     const Type* t = (ut != NULL) ? new UnionType(*ut) : yyvsp[0].type;
	     add_variable(*si, *t);
	   }
	   if (ut != NULL) {
	     delete ut;
	   }
	   delete yyvsp[-1].strings;
	 ;
    break;}
case 185:
#line 968 "pddl.yy"
{ yyval.strings = new vector<string>(1, *yyvsp[0].str); delete yyvsp[0].str; ;
    break;}
case 186:
#line 970 "pddl.yy"
{ yyvsp[-1].strings->push_back(*yyvsp[0].str); yyval.strings = yyvsp[-1].strings; delete yyvsp[0].str; ;
    break;}
case 187:
#line 973 "pddl.yy"
{ yyval.utype = new UnionType(make_type(*yyvsp[0].str)); delete yyvsp[0].str; ;
    break;}
case 188:
#line 974 "pddl.yy"
{ yyval.utype = yyvsp[-1].utype; yyval.utype->add(make_type(*yyvsp[0].str)); delete yyvsp[0].str; ;
    break;}
case 189:
#line 977 "pddl.yy"
{ yyval.type = yyvsp[0].type; ;
    break;}
case 190:
#line 980 "pddl.yy"
{ yyval.type = &make_type(*yyvsp[0].str); delete yyvsp[0].str; ;
    break;}
case 191:
#line 981 "pddl.yy"
{ yyval.type = &UnionType::simplify(*yyvsp[-1].utype); ;
    break;}
case 192:
#line 984 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 193:
#line 987 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 194:
#line 990 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 195:
#line 993 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 196:
#line 996 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 197:
#line 999 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 198:
#line 1002 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 199:
#line 1005 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 200:
#line 1008 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 201:
#line 1011 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 202:
#line 1014 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 203:
#line 1017 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 204:
#line 1020 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 205:
#line 1023 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 206:
#line 1026 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 207:
#line 1029 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
case 208:
#line 1032 "pddl.yy"
{ delete yyvsp[0].str; ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 543 "/usr/lib/bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif

  /* Now "shift" the result of the reduction.
     Determine what state that goes to,
     based on the state we popped back to
     and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
    {
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token
     after shifting the error token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;

 yyacceptlab:
  /* YYACCEPT comes here.  */
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#ifdef YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 0;

 yyabortlab:
  /* YYABORT comes here.  */
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#ifdef YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 1;
}
#line 1096 "pddl.yy"


/*
 * Converts an unsigned integer to a string.
 */
static string tostring(unsigned int n) {
  string result;
  while (n > 0) {
    result = char(n % 10 + '0') + result;
    n /= 10;
  }
  return (result.length() == 0) ? "0" : result;
}


/*
 * Outputs an error message.
 */
static void yyerror(const string& s) {
  cerr << PACKAGE << ':' << current_file << ':' << line_number << ": "
       << s << context << endl;
  success = false;
}


/*
 * Outputs a warning.
 */
static void yywarning(const string& s) {
  if (warning_level > 0) {
    cerr << PACKAGE << ':' << current_file << ':' << line_number << ": "
	 << s << context << endl;
    if (warning_level > 1) {
      success = false;
    }
  }
}


/*
 * Returns the type with the given name, or NULL if it is undefined.
 */
static const SimpleType* find_type(const string& name) {
  if (pdomain != NULL) {
    return pdomain->find_type(name);
  } else if (domain != NULL) {
    return domain->find_type(name);
  } else {
    return NULL;
  }
}


/*
 * Returns the constant or object with the given name, or NULL if it
 * is undefined.  */
static const Name* find_constant(const string& name) {
  const Name* c = NULL;
  if (pdomain != NULL) {
    c = pdomain->find_constant(name);
  }
  if (c == NULL && domain != NULL) {
    c = domain->find_constant(name);
  }
  if (c == NULL && problem != NULL) {
    c = problem->find_object(name);
  }
  return c;
}


/*
 * Returns the predicate with the given name, or NULL if it is
 * undefined.
 */
static const Predicate* find_predicate(const string& name) {
  if (pdomain != NULL) {
    return pdomain->find_predicate(name);
  } else if (domain != NULL) {
    return domain->find_predicate(name);
  } else {
    return NULL;
  }
}


/*
 * Adds types, constants, or objects to the current domain or problem.
 */
static void add_names(const vector<string>& names, const Type& type) {
  const UnionType* ut = dynamic_cast<const UnionType*>(&type);
  for (vector<string>::const_iterator si = names.begin();
       si != names.end(); si++) {
    /* Duplicate type if it is a union type so that every name has its
       own copy. */
    const Type* t = (ut != NULL) ? new UnionType(*ut) : &type;
    const string& s = *si;
    if (name_map_type == TYPE_MAP) {
      if (find_type(s) == NULL) {
	domain->add_type(*(new SimpleType(s, *t)));
      } else {
	yywarning("ignoring repeated declaration of type `" + s + "'");
      }
    } else if (name_map_type == CONSTANT_MAP) {
      const Name* old_name = domain->find_constant(s);
      if (old_name != NULL) {
	domain->add_constant(*(new Name(s, UnionType::add(old_name->type(),
							  *t))));
	delete old_name;
	if (ut != NULL) {
	  delete t;
	}
      } else {
	domain->add_constant(*(new Name(s, *t)));
      }
    } else {
      if (pdomain->find_constant(s) != NULL) {
	yywarning("ignoring declaration of object `" + s
		  + "' previously declared as constant");
      } else {
	const Name* old_name = problem->find_object(s);
	if (old_name == NULL) {
	  problem->add_object(*(new Name(s, *t)));
	} else {
	  problem->add_object(*(new Name(s,
					 UnionType::add(old_name->type(),
							*t))));
	  delete old_name;
	  if (ut != NULL) {
	    delete t;
	  }
	}
      }
    }
  }
  if (ut != NULL) {
    delete ut;
  }
}


/*
 * Adds a predicate to the current domain.
 */
static void add_predicate(const Predicate& predicate) {
  if (find_predicate(predicate.name()) == NULL) {
    if (find_type(predicate.name()) == NULL) {
      domain->add_predicate(predicate);
    } else {
      yywarning("ignoring declaration of predicate `" + predicate.name()
		+ "' in domain `" + domain->name()
		+ "' previously declared as type");
      delete &predicate;
    }
  } else {
    yywarning("ignoring repeated declaration of predicate `" + predicate.name()
	      + "' in domain `" + domain->name() + "'");
    delete &predicate;
  }
}


/*
 * Adds an action schema to the current domain.
 */
static void add_action(const ActionSchema& action) {
  if (domain->find_action(action.name()) != NULL) {
    yywarning("ignoring repeated declaration of action `" + action.name()
	      + "' in domain `" + domain->name() + "'");
    delete &action;
  } else {
    domain->add_action(action);
  }
}


/*
 * Adds a variable to the current context.
 */
static void add_variable(const string& name, const Type& type) {
  if (predicate != NULL) {
    predicate->add_parameter(type);
  } else {
    if (free_variables.shallow_find(name) != NULL) {
      yyerror("repetition of parameter `" + name + "'");
    } else if (free_variables.find(name) != NULL) {
      yyerror("shadowing parameter `" + name + "'");
    }
    const Variable* var = new Variable(name, type);
    free_variables.insert(var);
    variables->push_back(var);
  }
}


/*
 * Creates an add/delete list pair.
 */
static const pair<AtomList*, NegationList*>& make_add_del(AtomList* adds,
							  NegationList* dels) {
  return *(new pair<AtomList*, NegationList*>(adds, dels));
}


/*
 * Creates a formula (predicate terms[0] ...).
 */
static const Atom& make_atom(const string& predicate, const TermList& terms) {
  const Predicate* p = find_predicate(predicate);
  if (p == NULL) {
    if (find_type(predicate) != NULL && terms.size() != 1) {
      yyerror(tostring(terms.size())
	      + "parameters passed to type predicate `" + predicate + "'");
    }
    if (domain != NULL) {
      Predicate* new_p = new Predicate(predicate);
      for (size_t i = 0; i < terms.size(); i++) {
	new_p->add_parameter(SimpleType::OBJECT);
      }
      domain->add_predicate(*new_p);
      p = new_p;
      yywarning("implicit declaration of predicate `" + predicate + "'");
    } else {
      yyerror("undeclared predicate `" + predicate + "' used");
    }
  } else if (p->arity() != terms.size()) {
    yyerror(tostring(terms.size()) + " parameter"
	    + string((terms.size() == 1) ? "" : "s")
	    + " passed to predicate `" + predicate
	    + "' expecting " + tostring(p->arity()));
  }
  return *(new Atom(*p, terms, formula_time));
}


/*
 * Adds a name to the given name term list.
 */
static TermList& add_name(TermList& terms, const string& name) {
  const Name* c = find_constant(name);
  if (c == NULL) {
    const Predicate* predicate = find_predicate(current_predicate);
    if (predicate == NULL || predicate->arity() <= terms.size()) {
      c = new Name(name, SimpleType::OBJECT);
    } else {
      c = new Name(name, predicate->type(terms.size()));
    }
    if (domain != NULL) {
      domain->add_constant(*c);
      yywarning("implicit declaration of constant `" + name + "'");
    } else {
      problem->add_object(*c);
      yywarning("implicit declaration of object `" + name + "'");
    }
  }
  terms.push_back(c);
  return terms;
}


static const SimpleType& make_type(const string& name) {
  const SimpleType* t = find_type(name);
  if (t == NULL) {
    const SimpleType& st = *(new SimpleType(name));
    if (domain != NULL) {
      domain->add_type(st);
      yywarning("implicit declaration of type `" + name + "'");
    } else {
      yyerror("undeclared type `" + name + "' used");
    }
    return st;
  } else {
    return *t;
  }
}
